package com.example.swagger;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

@Slf4j
@SpringBootApplication
public class SwaggerApplication {

    @SneakyThrows
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(SwaggerApplication.class);
        ConfigurableApplicationContext context = springApplication.run(args);

        Environment env = context.getEnvironment();
        log.info("""
                        
                        ----------------------------------------------------------
                        \t\
                        Application '{}' is running! Access URLs:
                        \t\
                        Swagger-Ui: \thttp://localhost:{}/swagger-ui.html
                        \t\
                        Api-Docs: \t\thttp://{}:{}/v3/api-docs
                        \t\
                        Knife4j: \t\thttp://{}:{}/doc.html
                        ----------------------------------------------------------""",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"));
    }
}
